package com.wodsy.phoenix.dataobject.goodsc.model;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.GenericGenerator;

import com.wodsy.phoenix.dataobject.goodsc.constants.GoodsStatu;

/**
 * TbGoods entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "tb_goods", catalog = "goodsc")
public class Goods implements java.io.Serializable {

	// Fields
	private static final long serialVersionUID = 1L;
	
	private Integer id;
	private String name;		//商品名称
	private String title;		//商品副标题
	private Integer place;		//商品产地对应的城市字典表的最下一级的城市id
	private String number;		//商品编号
	private String description;			//商品描述(这个只是存储的一个描述的html地址)
	private Boolean producerType;		//是否创者
	private Integer shopId;				//商品对应的店铺id
	private Boolean virtual;			//商品介质，0实物 1虚拟
	private Boolean priceless;			//非卖品标识，0为非卖品 1为可卖
	private Integer ftId;				//运费模版id
	private Date addTime;				//商品添加时间
	private Date updateTime;			//商品最后修改时间
	private Boolean customization;			//是否定制，1为定制
	private GoodsStatu status;			//商品状态0:未发布 1：已发布，未审核 2：已上架  3：审核未通过 4：下架
	private Integer price;				//商品设置的默认价格
	private String pic;				//商品默认图片
	private String piclist;			//商品展示图组

	private Set<GoodsSku> goodsSku = new HashSet<>(1);
	private Set<GoodsTag> goodsTag = new HashSet<>(1);
	private Set<GoodsMaterial> goodsMaterial = new HashSet<>(1);
	
	// Constructors

	/** default constructor */
	public Goods() {
	}

	/** minimal constructor */
	public Goods(String name, String number, Integer shopId, Integer ftId,
			Date addTime) {
		this.name = name;
		this.number = number;
		this.shopId = shopId;
		this.ftId = ftId;
		this.addTime = addTime;
	}

	/** full constructor */
	public Goods(String name, String title, Integer place, String number,
			String description, Boolean producerType, Integer shopId,
			Boolean virtual, Boolean priceless, Integer ftId,
			Date addTime, Date updateTime, Boolean customization,
			GoodsStatu status, Integer price, String pic, String piclist) {
		this.name = name;
		this.title = title;
		this.place = place;
		this.number = number;
		this.description = description;
		this.producerType = producerType;
		this.shopId = shopId;
		this.virtual = virtual;
		this.priceless = priceless;
		this.ftId = ftId;
		this.addTime = addTime;
		this.updateTime = updateTime;
		this.customization = customization;
		this.status = status;
		this.price = price;
		this.pic = pic;
		this.piclist = piclist;
	}

	// Property accessors
	@GenericGenerator(name = "generator", strategy = "increment")
	@Id
	@GeneratedValue(generator = "generator")
	@Column(name = "id", unique = true, nullable = false)
	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	@Column(name = "name", nullable = false, length = 50)
	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Column(name = "title", length = 50)
	public String getTitle() {
		return this.title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	@Column(name = "place")
	public Integer getPlace() {
		return this.place;
	}

	public void setPlace(Integer place) {
		this.place = place;
	}

	@Column(name = "number", nullable = false, length = 11)
	public String getNumber() {
		return this.number;
	}

	public void setNumber(String number) {
		this.number = number;
	}

	@Column(name = "description", length = 56)
	public String getDescription() {
		return this.description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	@Column(name = "producer_type")
	public Boolean getProducerType() {
		return this.producerType;
	}

	public void setProducerType(Boolean producerType) {
		this.producerType = producerType;
	}

	@Column(name = "shop_id", nullable = false)
	public Integer getShopId() {
		return this.shopId;
	}

	public void setShopId(Integer shopId) {
		this.shopId = shopId;
	}

	@Column(name = "virtual")
	public Boolean getVirtual() {
		return this.virtual;
	}

	public void setVirtual(Boolean virtual) {
		this.virtual = virtual;
	}

	@Column(name = "priceless")
	public Boolean getPriceless() {
		return this.priceless;
	}

	public void setPriceless(Boolean priceless) {
		this.priceless = priceless;
	}

	@Column(name = "ft_id", nullable = false)
	public Integer getFtId() {
		return this.ftId;
	}

	public void setFtId(Integer ftId) {
		this.ftId = ftId;
	}

	@Column(name = "add_time", nullable = false, length = 19)
	public Date getAddTime() {
		return this.addTime;
	}

	public void setAddTime(Date addTime) {
		this.addTime = addTime;
	}

	@Column(name = "update_time", length = 19)
	public Date getUpdateTime() {
		return this.updateTime;
	}

	public void setUpdateTime(Date updateTime) {
		this.updateTime = updateTime;
	}

	@Column(name = "customization")
	@Enumerated(EnumType.ORDINAL)
	public Boolean getCustomization() {
		return this.customization;
	}

	public void setCustomization(Boolean customization) {
		this.customization = customization;
	}

	@Column(name = "status")
	public GoodsStatu getStatus() {
		return this.status;
	}

	public void setStatus(GoodsStatu status) {
		this.status = status;
	}

	@Column(name = "price")
	public Integer getPrice() {
		return this.price;
	}

	public void setPrice(Integer price) {
		this.price = price;
	}

	@Column(name = "pic", length = 100)
	public String getPic() {
		return this.pic;
	}

	public void setPic(String pic) {
		this.pic = pic;
	}

	@Column(name = "piclist", length = 200)
	public String getPiclist() {
		return this.piclist;
	}

	public void setPiclist(String piclist) {
		this.piclist = piclist;
	}

	@OneToMany(fetch=FetchType.EAGER,cascade={CascadeType.ALL})//只级联保存
	@JoinColumn(name="goods_id")
	public Set<GoodsSku> getGoodsSku() {
		return goodsSku;
	}

	public void setGoodsSku(Set<GoodsSku> goodsSku) {
		this.goodsSku = goodsSku;
	}

	@OneToMany(fetch=FetchType.EAGER,cascade={CascadeType.ALL})//只级联保存
	@JoinColumn(name="goods_id")
	public Set<GoodsTag> getGoodsTag() {
		return goodsTag;
	}

	public void setGoodsTag(Set<GoodsTag> goodsTag) {
		this.goodsTag = goodsTag;
	}
	
	@OneToMany(fetch=FetchType.EAGER,cascade={CascadeType.ALL})//只级联保存
	@JoinColumn(name="goods_id")
	public Set<GoodsMaterial> getGoodsMaterial() {
		return goodsMaterial;
	}

	public void setGoodsMaterial(Set<GoodsMaterial> goodsMaterial) {
		this.goodsMaterial = goodsMaterial;
	}
	
}